import os

def build_go(source, target=None, cflags=""):
    suffix = ".out"
    if target == None:
        if type(source) is list:
            target = os.path.splitext(source[0])[0] + suffix
        elif type(source) is str:
            file = source
            # if " " in source: --> find 更高效
            if source.find(" ") != -1:
                file = source.split(" ")[0]
            target = os.path.splitext(file)[0] + suffix
    print("target:", target)
    Command( target, source, 'go build -gcflags="-N -l" -o ${TARGET} ${SOURCE}')

# build_go("main.go")
# build_go("main.go","main.exe")
# build_go("main_cal.go sub.go add.go")
# build_go(["main_cal.go", "add.go", "sub.go"])
# build_go(["src/main_cal.go","lib/add.go", "lib/sub.go"])
build_go("1_hello_world.go")
